/*
 * @Author: your name
 * @Date: 2022-03-06 16:57:32
 * @LastEditTime: 2022-03-18 22:24:26
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \driving\src\main.ts
 */
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { HttpExceptionFilter } from './core/filter/http-exception.filter';
import { TransformInterceptor } from './core/interceptor/transform.interceptor';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.enableCors();
  // 注册全局拦截器
  app.useGlobalInterceptors(new TransformInterceptor())
  // 注册全局错误过滤器
  app.useGlobalFilters(new HttpExceptionFilter()) 
  // 设置swagger文档
  const config = new DocumentBuilder()
    .setTitle('管路后台')
    .setDescription('管理后台接口文档')
    .setVersion('1.0')
    .addBearerAuth()
    .build();
  const document = SwaggerModule.createDocument(app,config)
  SwaggerModule.setup('driving',app,document)
  await app.listen(8888);
}
bootstrap();
